﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using Hi_Baidu.ProcessModel;

namespace Hi_Baidu.Timer
{
    /// <summary>
    ///     提供了获取自身信息请求超时计算和处理
    /// </summary>
    class GetMySelfInfomation_TimeOutEvent : TimeOutEvent
    {
        private String username;

        public GetMySelfInfomation_TimeOutEvent(String username, String Key, int Interval, int TryCount)
            : base(Key, Interval, TryCount)
        {
            this.username = username;
            this.OnTick += new EventHandler<EventArgs>(GetMySelfInfomation_TimeOutEvent_OnTick);
            this.OnTryFull += new EventHandler<EventArgs>(GetMySelfInfomation_TimeOutEvent_OnTryFull);
        }

        void GetMySelfInfomation_TimeOutEvent_OnTick(object sender, EventArgs e)
        {
            //重试请求
            GetInfomationModel.GetUserInfo(Encoding.Default.GetBytes(this.username));
        }

        void GetMySelfInfomation_TimeOutEvent_OnTryFull(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new PUBLIC_DELEGATE(Globle.ShowWindow));
        }
    }
}
